<html>

<head>
<?php include("../../MerchandiseBay/conn.php"); ?>
<?
$id=$_REQUEST['id'];
$sqlReservation = "SELECT * FROM merchandise, reservationdetail where merchandise.regno = reservationdetail.code and reservationId = $id";

$qryReservation=mysql_query($sqlReservation,$conn);
$sqlReserve = 'select * from reservation where id = '.$id;
$qryReserveData=mysql_query($sqlReserve,$conn);
$rowReserveData=mysql_fetch_assoc($qryReserveData);
$sqlUser = 'select * from users where username="'.$rowReserveData['name'].'"';
$qryUser=mysql_query($sqlUser, $conn);
$rowUser = mysql_fetch_assoc($qryUser);

$sqlItem = 'select * from `reservationdetail` where reservationId = '. $id;
$qryItem = mysql_query($sqlItem, $conn);
	function getName($sCode, $conn)
	{
		$sql = 'select kind from merchandise where regno = "'.$sCode.'"';

		$result=mysql_query($sql,$conn);
		while($result=mysql_fetch_assoc($result))
		{
			return $result['kind'];
		}
		
	}
//$sqlUpdate="update reservation set status='check' where id='$id'";
//$qryUpdate=mysql_query($sqlUpdate,$conn);

$row=mysql_fetch_assoc($qryReservation);
?>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>reservation information</title>
<script type="text/javascript">
window.onload = function()
{
	document.getElementById('button1').onclick = function(){history.back(1)};
}
</script>
</head>

<body bgcolor="#0099FF">
<div><div>
<div>
  <table width="486" border="0">
    <tr>
      <td width="12">&nbsp;</td>
      <td width="464" bgcolor="#800000"><div align="center"><font size="2" face="Verdana" color="#C0C0C0">&nbsp;<b>Reservation 
        Information </b></font></div></td>
    </tr>
  </table>
  <table border="0" width="66%" id="table1">
    <tr> 
      <td></td>
		
     
    </tr>
    <tr>
      <td width="231" align="right"><b><font size="2" face="Verdana">Reservation Id:  </font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana">&nbsp; 
	  <?php echo $id; ?></font></td>
    </tr>
    <tr> 
      <td width="231" align="right"><b><font size="2" face="Verdana">Name : </font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana">&nbsp; 
        <?=$rowUser['lastname'].' '.$rowUser['firstname'] ?>
        </font></td>
    </tr>
    <tr> 
      <td width="231" align="right"><b><font size="2" face="Verdana">Tel No :</font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana">&nbsp; 
        <?=$rowUser['telno']?>
        </font></td>
    </tr>
    <tr> 
      <td width="231" align="right"><b><font size="2" face="Verdana">Email :</font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana">&nbsp; 
        <?=$rowUser['email']?>
        </font></td>
    </tr>
    <tr> 
      <td width="231" align="right"><b><font size="2" face="Verdana">Reservation 
        Date:</font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana">&nbsp; 
        <?=$rowReserveData['reservationdate']?>
        </font></td>
    </tr>
	<tr> 
      <td width="231" align="right"><b><font size="2" face="Verdana">Reservation 
        Time:</font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana">&nbsp; 
        <?=$rowReserveData['reservationTime']?>
        </font></td>
    </tr>
    <tr> 
      <td width="231" align="right"><b><font size="2" face="Verdana">Address :</font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana">&nbsp; 
        <?=$rowUser['location']?>
        </font></td>
    </tr>
    <tr>
      <td align="right"><b><font size="2" face="Verdana">Code Product :</font></b></td>
      <td colspan="3" align="left"><font size="2" face="Verdana"> &nbsp; 
        <?=$row['code']?>
        </font></td>
    </tr>
    <tr> 
      <td width="231" align="right"><b><font size="2" face="Verdana">Ordered item:</font></b></td>
      <td width="144" align="left">Code</td>
      <td width="152" align="left">Name</td>
      <td width="110" align="left">Quantity</td>
    </tr>
    <?php $i=1;while($rowItem=mysql_fetch_assoc($qryItem)){ ?>
    <tr> 
      <td width="231" align="right"><?php echo $i; ?></td>
      <td align="left"><?php echo $rowItem['code']; ?></td>
      <td align="left"><?php echo getName($rowItem['code'],$conn); ?></td>
      <td align="left"><?php echo $rowItem['quantity']; ?></td>
    </tr>
    <?php  $i+=1;} ?>
  </table>
  <p>
  <input id="button1" type="button" value="back" />
  &nbsp;</p>
  <!--<table width="379" border="0">
    <tr>
      <td width="90">&nbsp;</td>
      <td width="117"><a href="adminHome.php">
      </a>
        <div align="center"><a href="listReservation.php">
          <div align="right"><strong>Accept</strong></div>
        </a></div>
      <a href="adminHome.php"></a></td>
      <td width="158"><a href="deleteNewReservation.php?d=<?=$id?>">
      <div align="center"><strong>Reject</strong></div>
      </a></td>
    </tr>
  </table>-->
  <p>&nbsp;</p>
</div>

</body>

</html>
